import React from 'react'
import { Provider } from 'react-redux';
import NavigationService from '@/services/NavigationService'
import { TopLevelNavigator } from '@/navigators'
import { PersistGate } from 'redux-persist/integration/react'
import configureStore from '@/store/configureStore'

const { store, persistor }  = configureStore()

class App extends React.Component {
  render() {
    return (
      <TopLevelNavigator
        ref={navigatorRef => {
          NavigationService.setTopLevelNavigator(navigatorRef);
        }}
      />
    );
  }
}

class ReduxApp extends React.Component {
  render() {
    return (
      <Provider store={store}>
        <PersistGate loading={null} persistor={persistor}>
          <App />
        </PersistGate>
      </Provider>
    )
  }
}

export default ReduxApp;